package com.school.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;
import com.school.pojo.Leave;
import com.school.service.LeaveService;
import com.school.util.Result;
import com.school.util.Tool;

@RequestMapping("/leave")
@RestController
public class LeaveController implements Tool<Leave>{

	@Autowired 
	private LeaveService leaveService;

	@Override
	@RequestMapping("/findAll")
	public Result<Leave> findAll(int page, int pageSize, Leave t) {
		List<Leave> list=leaveService.findAll(page,pageSize,t);
		
		PageInfo<Leave> info=new PageInfo<>(list);
		
		Result<Leave> result=new Result<Leave>();
		
		result.setList(info.getList());
		result.setCount(info.getTotal());
		return result;
	}

	@Override
	@RequestMapping("/findById")
	public Result<Leave> findbyId(int id) {
		List<Leave> leaves=leaveService.findbyId(id);
		Result<Leave> result=new Result<Leave>();
		result.setList(leaves);
		return result;
	}

	@Override
	public int add(Leave t) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int edit(Leave t) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int del(int id) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	@RequestMapping("/delbatch")
	public int delbatch(int[] id) {
		
		return leaveService.delbatch(id);
	}
	
	
	
}
